//
//  SearchTextTimeViewCell.m
//  XTCloud
//
//  Created by QA on 2017/9/5.
//  Copyright © 2017年 ShangHai HaoLei Software Technology Co., Ltd. All rights reserved.
//

#import "SearchTextTimeViewCell.h"

@implementation SearchTextTimeViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"SearchTextTimeViewCell" owner:self options:nil];
        self = [topLevelObjects objectAtIndex:0];
    }
    
    return self;
}

- (void)setFrame:(CGRect)frame
{
    frame.origin.x += 10;
    frame.size.width = SuperWidth - 20;
    [super setFrame:frame];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    
    // Alignment
    _tagsView.alignment = TTGTagCollectionAlignmentFillByExpandingWidth;
    
    // Use manual calculate height
    _tagsView.manualCalculateHeight = YES;
}

- (void)setTags:(NSArray<NSString *> *)tags {
    [_tagsView removeAllTags];
    [_tagsView addTags:tags];
    
    // Use manual height, update preferredMaxLayoutWidth
    _tagsView.preferredMaxLayoutWidth = [UIScreen mainScreen].bounds.size.width - 40;
    
    // Random selected
    for (NSInteger i = 0; i < 3; i++) {
        [_tagsView setTagAtIndex:arc4random_uniform((uint32_t)tags.count) selected:YES];
    }
}

@end
